﻿<UserControl x:Class="Supremacy.Client.Views.TaskForceListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:scc="http://schemas.startreksupremacy.com/xaml/presentation"
             xmlns:views="clr-namespace:Supremacy.Client.Views"
             TextBlock.FontSize="14pt">

  <UserControl.Resources>
    <Style x:Key="TaskForceListItemContainerStyle"
           TargetType="{x:Type ListViewItem}">
      <Setter Property="KeyboardNavigation.IsTabStop"
              Value="False" />
      <Setter Property="FocusVisualStyle"
              Value="{x:Null}" />
      <!--<Setter Property="scc:DragDropManager.DragSourceAdvisor" Value="{scc:Activator Type={x:Type views:TaskForceDragSourceAdvisor}}" />
      <Setter Property="scc:DragDropManager.DropTargetAdvisor" Value="{scc:Activator Type={x:Type views:TaskForceDropTargetAdvisor}}" />-->
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListViewItem}">
            <Grid x:Name="ItemContainerGrid"
                  Margin="0,4,0,0">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Border x:Name="SelectionOuterBorder"
                      Width="45"
                      Height="40"
                      Background="Transparent"
                      VerticalAlignment="Top">
                <Border x:Name="SelectionBorder"
                        Grid.Column="0"
                        Width="34"
                        Height="34"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">
                  <Border.Background>
                    <ImageBrush Stretch="Uniform"
                                ImageSource="{Binding Path=Source.Owner, Converter={StaticResource CivInsigniaConverter}}" />
                  </Border.Background>
                </Border>
              </Border>
              <ContentPresenter Grid.Column="1"
                                Margin="3,0,7,0" />
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected"
                       Value="True">
                <Setter TargetName="SelectionOuterBorder"
                        Property="Background"
                        Value="{DynamicResource FleetSelectionBorderBrush}" />
              </Trigger>
              <Trigger Property="views:TaskForceListView.IsOrderMenuOpened"
                       Value="True">
                <Setter TargetName="SelectionOuterBorder"
                        Property="Background"
                        Value="{DynamicResource FleetSelectionBorderBrush}" />
              </Trigger>
              <DataTrigger Binding="{Binding Path=Source.IsCloaked}"
                           Value="True">
                <Setter TargetName="SelectionBorder"
                        Property="Opacity"
                        Value="0.33" />
              </DataTrigger>
              <DataTrigger Binding="{Binding Path=Source.IsInTow}"
                           Value="True">
                <Setter TargetName="ItemContainerGrid"
                        Property="Visibility"
                        Value="Collapsed" />
              </DataTrigger>
              <DataTrigger Binding="{Binding Path=IsPresenceKnown}"
                           Value="False">
                <Setter Property="Visibility"
                        Value="Collapsed" />
              </DataTrigger>
              <DataTrigger Binding="{Binding Path=IsOwnerKnown}"
                           Value="False">
                <Setter TargetName="SelectionBorder"
                        Property="Background">
                  <Setter.Value>
                    <ImageBrush Stretch="Uniform">
                      <ImageBrush.ImageSource>
                        <BitmapImage UriSource="vfs:///Resources/Images/Insignias/__unknown.png" />
                      </ImageBrush.ImageSource>
                    </ImageBrush>
                  </Setter.Value>
                </Setter>
              </DataTrigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
      <Setter Property="ContentTemplate">
        <Setter.Value>
          <DataTemplate>
            <StackPanel Orientation="Vertical"
                        DockPanel.Dock="Right"
                        VerticalAlignment="Center"
                        TextBlock.LineHeight="10pt">
              <TextBlock Foreground="{DynamicResource DefaultTextBrush}"
                         Text="{Binding Path=Name, Converter={StaticResource StringResourceConverter}, ConverterParameter=UpperCase}" />
              <TextBlock x:Name="OrderText"
                         Foreground="{DynamicResource HeaderTextBrush}"
                         Text="{Binding Path=Source.Order.DisplayText, Converter={StaticResource StringResourceConverter}, ConverterParameter=UpperCase}"
                         TextWrapping="Wrap"
                         TextTrimming="CharacterEllipsis" />
            </StackPanel>
            <DataTemplate.Triggers>
              <DataTrigger Binding="{Binding Path=IsOwned}"
                           Value="False">
                <Setter TargetName="OrderText"
                        Property="Visibility"
                        Value="Collapsed" />
              </DataTrigger>
            </DataTemplate.Triggers>
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </UserControl.Resources>

  <ListView x:Name="TaskForceList"
            FontFamily="{DynamicResource DefaultFont}"
            Focusable="False"
            KeyboardNavigation.TabNavigation="None"
            KeyboardNavigation.DirectionalNavigation="None"
            KeyboardNavigation.IsTabStop="False"
            Foreground="{DynamicResource DefaultTextBrush}"
            Background="Transparent"
            BorderThickness="0"
            ScrollViewer.CanContentScroll="False"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            ItemsSource="{Binding Path=TaskForces, Mode=OneWay}"
            SelectedItem="{Binding Path=SelectedTaskForce, Mode=TwoWay}"
            ItemContainerStyle="{StaticResource TaskForceListItemContainerStyle}" />

</UserControl>
